package cn.iocoder.aics.module.member.dal.mysql.chathistory;

import java.util.*;

import cn.iocoder.aics.framework.common.pojo.PageResult;
import cn.iocoder.aics.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.aics.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.aics.module.member.dal.dataobject.chathistory.ChatHistoryDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.aics.module.member.controller.admin.chathistory.vo.*;

/**
 * 聊天记录 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface ChatHistoryMapper extends BaseMapperX<ChatHistoryDO> {

    default PageResult<ChatHistoryDO> selectPage(ChatHistoryPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ChatHistoryDO>()
                .eqIfPresent(ChatHistoryDO::getType, reqVO.getType())
                .eqIfPresent(ChatHistoryDO::getUserId, reqVO.getUserId())
                .eqIfPresent(ChatHistoryDO::getQuestion, reqVO.getQuestion())
                .eqIfPresent(ChatHistoryDO::getAnswer, reqVO.getAnswer())
                .eqIfPresent(ChatHistoryDO::getContextId, reqVO.getContextId())
                .betweenIfPresent(ChatHistoryDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ChatHistoryDO::getId));
    }

}